#pragma once
#include "CoreDll.h"
#include "d3dx9.h"


class Mesh
{

public:
	Mesh(void);
	virtual ~Mesh(void);


	virtual bool loadFromXFile(const string & fileName,IDirect3DDevice9* device) = 0;
	virtual void draw(IDirect3DDevice9* device) = 0;
	virtual Dword getFVF() = 0;
	virtual size_t getBytesPerVertex() = 0;
	virtual size_t getFaceCount() {return faceCount;};
	virtual size_t getVertexCount() {return vertexCount;};
protected:

	IDirect3DVertexBuffer9 * vb;
	IDirect3DIndexBuffer9 * ib;
	size_t vertexCount ;
	size_t faceCount ;
};

class StaticMesh: public Mesh
{
public:
	struct Vertex
	{
		Vertex():x(0.f),y(0.f),z(0.f),nx(0.f),ny(0.f),nz(1.f),color(0xffffffff),u(0.f),v(1.f){}
		Real x,y,z;
		Real nx,ny,nz;
		Dword color;
		Real u,v;
		enum { FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1, };
	};
	virtual Dword getFVF() { return Vertex::FVF; }
	virtual size_t getBytesPerVertex() { return sizeof(Vertex); }
	virtual bool loadFromXFile(const string & fileName,IDirect3DDevice9* device);
	virtual void draw(IDirect3DDevice9* device);

};